package com.ygly.struts.href;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ygly.struts.actions.SqlAction;
import com.ygly.struts.models.Pro;
import com.ygly.struts.models.User;

public class HrefaAction extends ActionSupport {

	/**
	 * @return
	 */
	public List<Pro> prolist;
	public List<Pro> list = new ArrayList<Pro>();
	public List<Pro> getProlist() {
		return prolist;
	}
	public void setProlist(List<Pro> prolist) {
		this.prolist = prolist;
	}
	public String execute()throws Exception {
		// TODO Auto-generated method stub
		ActionContext ctx = ActionContext.getContext();
		HttpServletRequest request = (HttpServletRequest )ctx.get(ServletActionContext.HTTP_REQUEST);
		int id = Integer.parseInt(request.getParameter("id").toString());
		SqlAction sql = new SqlAction();
		sql.OpenConn();
		String query = "select * from pro where Com_Id='"+id+"'";
		ResultSet rs = sql.executeQuery(query);
		while(rs.next()){
			Pro pro = new Pro();
			pro.setId(rs.getInt("Id"));
			pro.setName(rs.getString("Name"));
			list.add(pro);
		}
		this.setProlist(list);
		return "SUCCESS";
	}
}